package main

import (
	"fmt"
	"math/rand"
	"time"
)

type Person struct {
	name string
	age  int
}

func (p *Person) isOdd(a int) bool {
	if a%2 == 0 {
		return false
	} else {
		return true
	}
}

func (p *Person) picture(a, b int, s string) {
	for i := 0; i < a; i++ {
		for j := 0; j < b; j++ {
			fmt.Printf("%v", s)
		}
		fmt.Println()
	}
}

func (p *Person) calculator(a, b int, s byte) int {
	res := 0
	switch s {
	case '+':
		res = a + b
	case '-':
		res = a - b
	case '*':
		res = a * b
	case '/':
		res = a / b

	}
	return res
}

func (p *Person) transpose(s [][]int) {
	s1 := make([][]int, len(s[0]))
	for _, v := range s {
		for _, v1 := range v {
			fmt.Printf("%v\t", v1)
		}
		fmt.Println()
	}

	for i := 0; i < len(s1); i++ {
		s1[i] = make([]int, len(s))
		for j := 0; j < len(s); j++ {
			s1[i][j] = s[j][i]
		}
	}
	fmt.Println()
	for _, v := range s1 {
		for _, v1 := range v {
			fmt.Printf("%v\t", v1)
		}
		fmt.Println()
	}
}

func main() {
	var p1 Person
	p1.age = 18
	p1.name = "cat"
	fmt.Println(p1.isOdd(5))
	p1.picture(3, 8, "*")
	fmt.Println(p1.calculator(10, 3, '/'))
	var s = make([][]int, 4)
	rand.Seed(time.Now().Unix())
	for i := 0; i < 4; i++ {
		s[i] = make([]int, 5)
		for j := 0; j < 5; j++ {
			s[i][j] = rand.Intn(101)
		}
	}
	p1.transpose(s)

}
